home *** CD-ROM | disk | FTP | other *** search
- var speed:Number = 0;
- var maxMove:Number = 15;
- var jumpSpeed:Number = -10;
- var totalMapas:Number = 6;
- var mapaActual:Number = 2;
- var mapaActual2:Number = 2;
- var charEscala:Number = 25;
- var wall:String = "";
- var jumping:Boolean = true;
- var falling:Boolean = true;
-
- function inicializarJogo():Void{
- _root.createEmptyMovieClip("fundo2",_root.getNextHighestDepth());
- _root.createEmptyMovieClip("fundo",_root.getNextHighestDepth());
- _root.fundo2.attachMovie("fundoLonginquo","fundoLonginquo1",fundo2.getNextHighestDepth());
- _root.fundo2.attachMovie("fundoLonginquo","fundoLonginquo2",fundo2.getNextHighestDepth());
- _root.fundo.attachMovie("chao","chao1",fundo.getNextHighestDepth());
- _root.fundo.attachMovie("chao","chao2",fundo.getNextHighestDepth());
- _root.attachMovie("char","char",_root.getNextHighestDepth());
- _root.fundo.cacheAsBitmap = true;
- _root.fundo2.cacheAsBitmap = true;
- _root.char.cacheAsBitmap = true;
- _root.fundo.chao1.gotoAndStop(1);
- _root.fundo.chao2.gotoAndStop(2);
- _root.fundo2.fundoLonginquo1.gotoAndStop(1);
- _root.fundo2.fundoLonginquo2.gotoAndStop(2);
- _root.fundo2._x = 0;
- _root.fundo2._y = 0;
- _root.fundo._x = 0;
- _root.fundo._y = Stage.height;
- _root.fundo2.fundoLonginquo1._x = 0;
- _root.fundo2.fundoLonginquo1._y = 0;
- _root.fundo2.fundoLonginquo2._x = _root.fundo2.fundoLonginquo1._width;
- _root.fundo2.fundoLonginquo2._y = 0;
- _root.fundo.chao1._x = 0;
- _root.fundo.chao1._y = 0;
- _root.fundo.chao2._x = fundo.chao1._width;
- _root.fundo.chao2._y = 0;
- _root.char._xscale = char._yscale = charEscala;
- _root.char._x = Stage.width/2;
- _root.char._y = Stage.height/2;
-
- }
- function detectarTeclas():Void{
- //atrito
- speed *= .85;
- if (Key.isDown(Key.LEFT) && wall != "esq") {
- wall = "";
- if (speed>-maxMove) {
- speed--;
- }
- } else if (Key.isDown(Key.RIGHT) && wall != "dir") {
- posicionarMapas();
- wall = "";
- if (speed<maxMove) {
- speed++;
- }
- }
- if (Key.isDown(Key.UP) && !jumping) {
- wall = "";
- jumping = true;
- }
- }
-
- function moverPersonagem():Void{
- var mc:MovieClip = _root.char;
- if (speed>0) {
- // andar para a Direita
- mc.play();
- mc._xscale = charEscala;
- if(mc._x < Stage.width/2){
- mc._x += speed;
- }else{
- mc._x += speed/50;
- fundo2._x -= speed/10;
- fundo._x -= speed;
- }
- } else if (speed<0) {
- // andar para a Esquerda
- if(mc._x <=0){
- mc._x = 0;
- }else{
- mc.play();
- mc._xscale = -charEscala;
- mc._x += speed;
- }
- }
- if (speed<1 && speed>-1) {
- // parado
- speed = 0;
- mc.gotoAndStop(1);
- }
- }
-
- inicializarJogo();
-
- onEnterFrame = function(){
- detectarTeclas();
- moverPersonagem();
- }